package com.example.myapplication.ui;

import android.app.Activity;
import android.os.Bundle;

import android.widget.ImageView;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.content.Intent;

import com.example.myapplication.R;
//启动页面
public class OpenActivity extends Activity {
    private ImageView welcomeImg = null; // 定义ImageView

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tupian); // 设置布局

        welcomeImg = (ImageView) this.findViewById(R.id.open_img); // 获取ImageView
        AlphaAnimation animation = new AlphaAnimation(0.5f, 1.0f); // 透明度动画从0.5到1.0
        animation.setDuration(3000); // 动画持续时间3000毫秒(3秒)
        welcomeImg.startAnimation(animation);
        animation.setAnimationListener(new AnimationImp1()); // 设置动画监听
    }

    private class AnimationImp1 implements Animation.AnimationListener {
        @Override
        public void onAnimationStart(Animation animation) {
            welcomeImg.setImageResource(R.drawable.bgg); // 设置图片资源
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            Intent intent = new Intent(OpenActivity.this, LoginActivity.class); // 创建Intent
            startActivity(intent); // 启动Intent
            finish(); // 结束当前Activity
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            // 动画重复时不需要操作，保持空实现
        }
    }
}